package ai.people.netmon.warning;

import com.huaban.analysis.jieba.JiebaSegmenter;
import com.huaban.analysis.jieba.SegToken;
import com.huaban.analysis.jieba.keyword.Keyword;
import com.huaban.analysis.jieba.keyword.TFIDFAnalyzer;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

public class SplitWord {

    private static String basePath = "C:\\Users\\ligua\\Downloads\\";
    public static void main(String[] args) throws IOException {
        test();
    }

    public static void test(){
        String content="孩子上了幼儿园 安全防拐教育要做好";
        int topN=5;
        TFIDFAnalyzer tfidfAnalyzer=new TFIDFAnalyzer();
        List<Keyword> list=tfidfAnalyzer.analyze(content,topN);
        for(Keyword word:list)
            System.out.println(word.getName()+":"+word.getTfidfvalue()+",");
        // 防拐:0.1992,幼儿园:0.1434,做好:0.1065,教育:0.0946,安全:0.0924
    }

    public void test2() throws Exception{
        String content = "Incompatibility with 0.9.44-0 router - I2P support forum I2P support forum Help, support, and discussion about I2P Skip to content Search Advanced search Quick links Unanswered topics Active topics Search Forums FAQ Login Register Search Login Register Board index 3rdParty I2P-Bote Search It is currently 11 May 2021 15:19 All times are UTC Incompatibility with 0.9.44-0 router Post Reply Print view Search Advanced search 1 post • Page 1 of 1 Cy-27 Posts: 3 Joined: 18 Jun 2018 15:01 Incompatibility with 0.9.44-0 router Quote Post by Cy-27 » 10 Dec 2019 13:01 I2P-Bote is not compatible with 0-9.44 router. Service does not start, control page - error 404. Reinstallation does not help. Top Post Reply Print view 1 post • Page 1 of 1 Return to “I2P-Bote” Jump to Announcements ↳   Blogentries ↳   Releases Guides I2P Router ↳   Router ↳   Susimail ↳   Addressbook ↳   I2PSnark ↳   Android Development ↳   Proposals ↳   I2P Laboratory 3rdParty ↳   I2P-Bote ↳   Plugins ↳   Syndie ↳   iMule ↳   Tahoe-LAFS ↳   MuWire ↳   BrowserBundle General ↳   Meetings ↳   Talks & Events ↳   Misc ↳   Hidden Service Announcements International ↳   Русский ↳   Deutsch ↳   Espanol ↳   العربية ↳   فارسی Forum Issues Board index All times are UTC Delete cookies Contact us Powered by phpBB ® Forum Software © phpBB Limited Style by Arty - phpBB 3.3 by MrGaby Privacy | Terms    ";
        //content = TextDealutil.specialCharacters(content);
        List<String> stopWords = FileUtils.readLines(new File(basePath + "stop_words.txt"));
        List<SegToken> result = new JiebaSegmenter().process(content, JiebaSegmenter.SegMode.INDEX);
        System.out.println("没有过滤停用词======" + result);
        List<String> collect = result.stream().map(o -> o.word.trim()).filter(o -> !NumberUtils.isDigits(o) && StringUtils.isNotBlank(o) && !stopWords.contains(o)).collect(Collectors.toList());
        System.out.println("过滤停用词=========" + collect);
    }
}
